<template>
    <div class="com-cnt">
        <div class="cardcon">
            <img :src="cardimg" alt="">
        </div>
        <div class="huitiao"></div>
        <ul class="infolist">
            <li>
                <h3>会员级别</h3>
                <span>{{userlevel}}</span>
            </li>
            <li>
                <h3>会员年限</h3>
                <span>{{years}}年</span>
            </li>
            <li>
                <h3>会员受益</h3>
                <span>每月返还{{termSource}}积分，累计返还{{totalTerm}}个月</span>
            </li>
        </ul>
    </div>
</template>

<script>
    import { domain } from '@/assets/js/config'
    
    import $ from 'jquery'
    import { maskTips } from '@/assets/js/dom'
    export default {
        name: 'gePage',
        components:{
            
        },
        data(){
            return{
                userToken: '',
                cardimg: '',
                userlevel: '',
                years: '',
                termSource: '',
                totalTerm: ''
            }
        },
        mounted ( ) {
            var that = this
            var userToken = localStorage.getItem("token")||'' //用户token值
            that.userToken = userToken
            $.ajax({
                    url : domain + "/xshk/f/user/getCardInfoByUserId?token=" + userToken,
                    
                    type:"post",
                    dataType : "json",
                    xhrFields: {withCredentials: true},
                    crossDomain: true,
                    headers: {
                        'Content-Type':'application/x-www-form-urlencoded'
                    },
                    success : function(data) {
                        console.log(data)
                        if(data.code === 0){
                            that.cardimg = data.data.picture
                            that.userlevel = data.data.name
                            that.years = data.data.period
                            that.termSource = data.data.termSource
                            that.totalTerm = data.data.totalTerm
                        }else{
                            console.log("data.message");
                            maskTips({id:"no-card",txt:'您还不是会员!'})
                            that.$router.push('/center')
                        }
                    },
                    error : function(){
                        console.log("通信失败");
                    }
                    
                })
        },
        methods : {
            
        }
    }
</script>

<style lang="stylus" scoped>
.com-cnt
    width 100%
    height 85%
    .cardcon
        width 100%
        padding 20px 20px
    img 
        width 100%
    .huitiao
        height 20px
        background #DDDDDD
    .infolist
        width 100%
        li 
            padding 20px 0 12px 20px
            border-bottom 1px solid #DDDDDD
            h3
                padding-bottom 13px
                // height 20px
                // line-height 18px
                font-size 18px
            span 
                font-size 14px
                display block
                padding 0
                height 14px
                line-height 14px
                color #999999
</style>